package com.cangxuan.manage.service.impl;

import com.cangxuan.manage.bean.Page;
import com.cangxuan.manage.dao.IUserDao;
import com.cangxuan.manage.dao.IUserGoodsDao;
import com.cangxuan.manage.entity.User;
import com.cangxuan.manage.entity.UserGoods;
import com.cangxuan.manage.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements IUserService {
    IUserDao userDao;
    IUserGoodsDao iUserGoodsDao;
    @Autowired
    public void setUserDao(IUserDao userDao) {
        this.userDao = userDao;
    }
    @Autowired
    public void setIUserGoodsDao(IUserGoodsDao iUserGoodsDao) {
        this.iUserGoodsDao = iUserGoodsDao;
    }

    @Override
    public Page<User> page(int pageIndex, int pageSize, int id, String mobile, String realName, String idcard,int realNameInfo) {
        Page<User> userPage = new Page<>(pageIndex, pageSize);
        userPage.setRecords(userDao.select(pageIndex, pageSize,id,mobile,realName,idcard,realNameInfo));
        userPage.setTotal(userDao.selectCount(id,mobile,realName, idcard,realNameInfo));
        return userPage;
    }


    @Override
    public List<User> isRealNamed() {
        return userDao.isRealNamed();
    }

    @Override
    public boolean changeState(Boolean available, int id) {
        return userDao.changeState(available,id)>0;
    }

    @Override
    public List<UserGoods> selectByUserID(int userID) {
        return iUserGoodsDao.selectByUserID(userID);
    }
    @Override
    public boolean changeSubscribe(Boolean subscribeToTheSalesCalendar, int id) {
        return userDao.changeSubscribe(subscribeToTheSalesCalendar,id)>0;
    }
    @Override
    public boolean changeDisplayMyGoods(Boolean displayMyGoods, int id) {
        return userDao.changeDisplayMyGoods(displayMyGoods,id)>0;
    }
    @Override
    public boolean changeDisplayMySellGoods(Boolean displayMySellGoods, int id) {
        return userDao.changeDisplayMySellGoods(displayMySellGoods,id)>0;
    }
}
